
package ma.crawler.mplayer.sogou.provider;

import android.text.TextUtils;

import ma.crawler.mplayer.sogou.model.SogouMusicInfo;
import ma.crawler.mplayer.sogou.parser.SogouMusicParser;
import ma.http.HttpUtils;

import java.util.List;

public class SogouMusicProvider {

    public List<SogouMusicInfo> search(String keyword) {
        SogouClient client = new SogouClient();
        String html = client.requestHtml(keyword);
        if (TextUtils.isEmpty(html)) {
            return null;
        }
        return SogouMusicParser.parse(html);
    }

    public static String getDownloadUrl(String pageUrl) {
        String html = HttpUtils.getUrlAsString(pageUrl);
        if (TextUtils.isEmpty(html)) {
            return null;
        }
        return SogouMusicParser.parseDownloadUrl(html);
    }

}
